package oa.web.controller;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import oa.core.Constant;
import oa.web.service.LoginService;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller

public class Login {
	
	@Autowired
	private LoginService loginService;
	
	@RequestMapping("login")
	public String index(HttpServletRequest req, HttpServletResponse rep, ModelMap map){
		String username = req.getParameter("username");
		String password = req.getParameter("password");
		
		int loginStatus = loginService.isLogin(username, password, req);
		System.out.print(loginStatus);
		if(loginStatus == Constant.LOGIN_STATUS_LOGIN_SUCCESS){
			return "index";
		}
		return "redirect:login.jsp";
	}

}
